package com.justnow.offer;

/**
 * @author justnow
 * Created on 2020-09-02
 * Description
 */
public class Solution2 {
    public int house (int[] person) {
        int length = person.length;
        int[] number = new int[length];
        int sum = 0;
        for (int i = 0; i < number.length; i++) {
            number[i] = 1;
        }

        if (person[0] > person[1])
            number[0] = 2;
        for (int i = 1; i < length; i++) {
            if (person[i] > person[i - 1])
                number[i] = number[i - 1] + 1;
        }
        for (int n : number) {
            //System.out.println(n);
            sum = sum + n;
        }
        return sum;


                /*
                int length = person.length;
        int sum = length;
        if (person[0] > person[1])
            sum++;
        for (int i = 1; i < length - 1; i++) {
            if (person[i + 1] > person[i])
                sum++;
        }
        return sum;
         */
    }

    public static void main(String[] args) {
        Solution2 solution2 = new Solution2();
        int[] array01 = {1, 3, 2, 2, 1};
        int house = solution2.house(array01);
        System.out.println(house);

    }
}
